package com.houweishi.module.clockaddress.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.houweishi.common.annotation.Log;
import com.houweishi.common.core.controller.BaseController;
import com.houweishi.common.core.domain.AjaxResult;
import com.houweishi.common.enums.BusinessType;
import com.houweishi.module.clockaddress.domain.BizClockAddress;
import com.houweishi.module.clockaddress.service.IBizClockAddressService;
import com.houweishi.common.utils.poi.ExcelUtil;
import com.houweishi.common.core.page.TableDataInfo;

/**
 * 打卡地址管理Controller
 * 
 * @author houweishi
 * @date 2023-02-28
 */
@RestController
@RequestMapping("/module/clockaddress")
public class BizClockAddressController extends BaseController
{
    @Autowired
    private IBizClockAddressService bizClockAddressService;

    /**
     * 查询打卡地址管理列表
     */
    @PreAuthorize("@ss.hasPermi('module:clockaddress:list')")
    @GetMapping("/list")
    public TableDataInfo list(BizClockAddress bizClockAddress)
    {
        startPage();
        List<BizClockAddress> list = bizClockAddressService.selectBizClockAddressList(bizClockAddress);
        return getDataTable(list);
    }

    /**
     * 导出打卡地址管理列表
     */
    @PreAuthorize("@ss.hasPermi('module:clockaddress:export')")
    @Log(title = "打卡地址管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BizClockAddress bizClockAddress)
    {
        List<BizClockAddress> list = bizClockAddressService.selectBizClockAddressList(bizClockAddress);
        ExcelUtil<BizClockAddress> util = new ExcelUtil<BizClockAddress>(BizClockAddress.class);
        util.exportExcel(response, list, "打卡地址管理数据");
    }

    /**
     * 获取打卡地址管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('module:clockaddress:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(bizClockAddressService.selectBizClockAddressById(id));
    }

    /**
     * 新增打卡地址管理
     */
    @PreAuthorize("@ss.hasPermi('module:clockaddress:add')")
    @Log(title = "打卡地址管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BizClockAddress bizClockAddress)
    {
        return toAjax(bizClockAddressService.insertBizClockAddress(bizClockAddress));
    }

    /**
     * 修改打卡地址管理
     */
    @PreAuthorize("@ss.hasPermi('module:clockaddress:edit')")
    @Log(title = "打卡地址管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BizClockAddress bizClockAddress)
    {
        return toAjax(bizClockAddressService.updateBizClockAddress(bizClockAddress));
    }

    /**
     * 删除打卡地址管理
     */
    @PreAuthorize("@ss.hasPermi('module:clockaddress:remove')")
    @Log(title = "打卡地址管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(bizClockAddressService.deleteBizClockAddressByIds(ids));
    }
}
